package cj.web.marriage.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriage.domain.VoteResults;

/**
 * 
 * @author 
 *
 */
@DAO
public interface VoteResultsDAO{
	
	@SQL("SELECT * FROM VoteResults WHERE deleteFlag=1 #if(:t.voteId!=-1){ AND voteId=:t.voteId } ORDER BY createAt DESC LIMIT :t.start,:t.length ")
    List<VoteResults> query(@SQLParam("t") VoteResults voteResults);
		
	@SQL("SELECT count(1) FROM VoteResults WHERE deleteFlag=1 #if(:t.voteId!=-1){ AND voteId=:t.voteId } ")
    int querySize(@SQLParam("t") VoteResults voteResults);
    
    @SQL("select * from VoteResults where id=:1")
    VoteResults queryById(int id);
    
    @SQL("INSERT INTO VoteResults ("
			        		+ "voteId,"
			        		+ "voteItemIds,"
			        		+ "requestIp,"
			        		+ "deleteFlag,"
			        		+ "createUser,"
			        		+ "createAt"
							+") VALUES ("
							+ ":t.voteId,"
							+ ":t.voteItemIds,"
							+ ":t.requestIp,"
							+ "1,"
							+ ":t.createUser,"
							+ "now()"
					+")")
    void create(@SQLParam("t") VoteResults voteResults);
    
    @SQL("UPDATE VoteResults SET deleteFlag=0 WHERE voteId=:1")
    void deleteByVoteId(int id);
}